import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

public class VideoPlayer {

    static void post() {

        for (int i = 17; i <= 17; i++) {

            Map<String, String> data = new HashMap<String, String>();
            data.put("courseid", i+"");

            try {
                String json = Jsoup.connect("http://weike.lanqiao.cn/course/getDayClassList.do")
                        .data(data)
                        .ignoreContentType(true)
                        .execute().body();

                System.out.println(json);

                JSONArray array = JSONObject.parseObject(json)
                        .getJSONArray("list");


                for (Object o : array) {
                    String className = ((JSONObject) o).getString("day_classname");
                    String vu = ((JSONObject) o).getString("videourl");

                    String videoUrl = "http://weike.lanqiao.cn/static/"+vu;


                    System.out.println(videoUrl.replace("html", "mp4")
                            .replace("content", "sources")
                    .replace("-", " "));
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        post();
//
//
//        int cid = 16;
//
//        try {
//            Document doc = Jsoup.connect("http://weike.lanqiao.cn/course/golisten.do?courseid=" + cid)
//                    .cookie("JSESSIONID", "730D7F4401FBF7A9807704A00648F0DD")
//                    .get();
//
//
//            System.out.println(doc.html());
//            for (Element e : doc.select("div.courseChapter")) {
//                System.out.println(e.text());
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }
}
